package com.kedao.util;

import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

public class IKUTtils {

	public static List<String> segWords(String txt) {
		List<String> result = new ArrayList<String>();
		Reader reader = new StringReader(txt);
		IKSegmenter segmentation = new IKSegmenter(reader, true);
		Lexeme lexeme = null;
		try {
			while ((lexeme = segmentation.next()) != null) {
				if (lexeme.getLexemeText().getBytes().length != lexeme
						.getLexemeText().length()
						&& lexeme.getLexemeText().length() > 1) {
					// && lexeme.getLexemeText().length() > 1
					result.add(lexeme.getLexemeText());
				}
			}
		} catch (Exception e) {
			System.err.println("IK分词出现错误：" + e.getMessage());
		}
		return result;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		List<String> l = segWords("经调查发现乳腺导管显示的是未见扩张情况，女性的乳头产生胰液，部分光点比较粗大。右乳由图形可以看出占位，左乳未见的占位。");
		System.out.println(l.toString());
	}

}
